Shader "Unlit/NewUnlitShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _ColorStart ("_ColorStart", Range(0,1)) = 0.0
        _ColorEnd ("_ColorEnd", Range(0,1)) = 1.0
        TAU ("TAU", Range(0.5,100)) = 1.0
        _Color1 ("_Color1", Color) = (1,1,1,1)
        _Color2 ("_Color2", Color) = (1,1,1,1)
     
    }
    SubShader
    {
        Tags {
             "RenderType"="transparent"
             "RenderQueue"="transparent"
        
         }
        LOD 100

        Pass
        {
            Cull Back
            Zwrite Off
            // ZTest GEqual
            ZTest LEqual
            Blend One One //additive
            // Blend DstColor Zero//mul

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            #define TAUU 6.28
            

            struct appdata
            {
                float4 vertex : POSITION;
                float3 normal : TEXCOORD0;
                float2 uv : TEXCOORD1;
            };

            struct v2f
            {
                float3 normal : TEXCOORD0;
                float2 uv : TEXCOORD1;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            float _ColorStart;
            float _ColorEnd;
            float TAU;
            float4 _Color1;
            float4 _Color2;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.normal = UnityObjectToWorldNormal(v.normal);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            // =======================================================================
            float InverseLerp(float a, float b, float value){
                return (value - a) / (b - a);
            }

// https://www.youtube.com/watch?v=kfM-yu0iQBk
            fixed4 frag (v2f i) : SV_Target
            {
                // sample the texture
                // fixed4 col = fixed4(0.5, 0.1, 0.2, 1.0);
                // // apply fog
                // UNITY_APPLY_FOG(i.fogCoord, col);
                // // return col;  
                // float t = InverseLerp(_ColorStart,_ColorEnd,i.uv.x);
                // t= saturate(t);
                // t= frac(t);
                // fixed4 finalCol  = lerp(_Color1, _Color2, t);
                // return finalCol;

// float xOffset = i.uv.y;
float xOffset = cos(i.uv.x*TAU*8)*0.01;
float t = cos((i.uv.y+xOffset -  _Time.y*0.1)*TAU*5)*0.5+0.5;
t *= 1-i.uv.y;
// t *= _Color1;
// return  t;
float topBottomRemover = (abs(i.normal.y)<0.999);
float waves = t*topBottomRemover;
float4 gradient = lerp(_Color1,_Color2,i.uv.y);

return gradient*waves;

            }
            ENDCG
        }
    }
}
